@extends('admin.master')
<script src="/js/admin/chargeRecordsNotes.js"></script>
@section('title', '充值记录')
	
@section('firstItem')
@parent
				<span class="linkBtn" onclick="window.location.href='/admin/device/chargeRecords'">充值管理</span> &raquo; 
				<span>充值记录</span>
				<input class="a_indexbg" type="hidden" value="chargerecords" />
@stop
@section('searchList')
@parent		
				<div class="seizeBox">充值状态(在"备注信息"的右上角显示)：</div>
				<p>支付成功</p>
				<p>充值成功</p>
				<p>撤销中</p>
				<p>撤销成功</p>
				<p>将离线充值</p>
@stop
@section('dataTables')
@parent
			<table class="rechargeNotes dataTables" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<td>序号</td>
						<td>设备编号</td>
						<td>用户名</td>
						<td>手机号码</td>
						<td style="width: 4%">剩余流量(L)</td>
						<td>剩余天数(D)</td>
						<td>购买模式</td>
						<td style="width: 4%">购买金额(元)</td>
						<td style="width: 4%">购买流量数(L)</td>
						<td style="width: 4%">购买天数(D)</td>
						<td>购买人</td>
						<td>后台充值人</td>
						<td style="width: 4%">撤销金额(元)</td>
						<td style="width: 4%">撤销流量数(L)</td>
						<td style="width: 4%">撤销天数(D)</td>
						<td>撤销操作人</td>
						<td style="width: 4%">价格(元)</td>
						<td>商户订单号</td>
						<td>备注信息</td>
						<td style="width:7%">时间</td>
						<td>撤销充值</td>
					</tr>
				</thead>
				<tbody>
					@for($i=0, $chargeRecordCount=count($charge_records); $i<$chargeRecordCount; $i++)
					<tr >
						<td>{{ $i+1 }}</td>
						<td class="deviceCodeCell devicecodeVal">{{ $charge_records[$i]->device->code }}</td>
						<td class="userNameCell">{{ $charge_records[$i]->device->installInfo->customer_name or '' }}</td>
						<td>{{ $charge_records[$i]->userInfo->phone or '' }}</td>
						<td class="revokeFluxCell">{{ $charge_records[$i]->residual_flow or '/' }}</td>
						<td class="revokeDaysCell">{{ $charge_records[$i]->time_limit or '/' }}</td>
						@if($charge_records[$i]->recharge_mode == 1)
						<td>套餐模式
						@else<td>计量模式
						@endif
						</td>
						<td>{{ $charge_records[$i]->money or 0 }}</td>
						<td>{{ $charge_records[$i]->flow }}</td>
						<td>{{ $charge_records[$i]->days }}</td>
						<td>{{ $charge_records[$i]->userInfo->name or '' }}</td>
						<td>{{ $charge_records[$i]->adminInfo->name or '' }}</td>
						<td >{{ is_null($charge_records[$i]->discharge_money)? '': $charge_records[$i]->discharge_money}}</td>
						<td>{{ is_null($charge_records[$i]->discharge_flow)? '': $charge_records[$i]->discharge_flow}}</td>
						<td>{{ is_null($charge_records[$i]->discharge_time)? '': $charge_records[$i]->discharge_time}}</td>
						<td class="revokeAddTextCell">{{ $charge_records[$i]->dischargeAdmin->name or '' }}</td>
						<td class="cancelPrice">{{ is_null($charge_records[$i]->price)? '': $charge_records[$i]->price}}</td>
						<td>{{ $charge_records[$i]->order_number or '' }}</td>
						<td class="addTextCell statusColorIcon{{$charge_records[$i]->status}}" style="width:180px;">{{ $charge_records[$i]->remark }}</td>
						<td >{{ $charge_records[$i]->created_at }}</td>
						@if($charge_records[$i]->status != 2)
						<td class="positionParent"><a class="revokeBtn cancelBg ">
						@else
						<td class="positionParent">
							<a class="revokeBtn">@endif修改</a>
							<input class="device_id" type="hidden" value="{{ $charge_records[$i]->device_id }}" />
							<input class="charge_record_id" type="hidden" value="{{ $charge_records[$i]->id }}" />
							<div class="modeBox">
								<a class="meterageMode">计量模式</a>
								<a class="packageMode">套餐模式</a>
							</div>
						</td>
					</tr>
					@endfor
				</tbody>
			</table>
@stop
@section('page_num')
<ul class="pagination pagination-lg"> 
	@if(!is_null($charge_records->first()))
	{!! $charge_records->appends(['device_id' => $charge_records->first()->device_id])->render() !!}
	@endif
</ul>
@stop
@section('infor_promit')
@parent
	<!-- 撤回流量框 -->
	<div class="payFlux revokeManage meterageM" >
		<div class="displayBox p_relative" style="margin: 0px auto;">
			<div>
				<p><span>设备编码:</span><label class="revokeDeviceCode"></label></p>
				<p><span>剩余流量(L):</span><label class="revokeResidueFlux"></label></p>
			</div>
			<div >
				<p><span>用户名:</span><label class="revokeGetUserName"></label></p>
				<p><span>剩余天数(D):</span><label class="revokeResidueDays"></label></p>
			</div>
			<div>
				<p><span>安装地址:</span><label class="revokeGetAddress"></label></p>
			</div>
			<p><textarea class="textareaBox revokeAddText" placeholder="备注信息："></textarea></p>
			<label style="color:#63C3D1;">每条充值记录只能撤销操作一次，请谨慎操作</label>
			<div class="payBox">撤回金额(元)：<input class="chargeFluxBox revokeFluxBox" type="text" placeholder="输入正整数" oninput="myFunction1()"/><label class="required">*</label></div>
			<div class="payBox">撤回单价(元)：<span class="revokePrice" style="margin-left: 20px;"></span></div>
			<div class="payBox">撤回流量(升)：<span class="fluxNumBox" style="margin-left: 20px;"></span></div>
			<div><label class="labelBox"></label></div>
		</div>
		<div class="btnBox" style="margin-top: 0px;">
			<a class="noBtn revokeNoBtn">取消</a>
			<a class="okBtn revokeOkBtn">确定</a>
		</div>
	</div>

	<div class="payFlux revokeManage packageM" >
		<div class="displayBox p_relative" style="margin: 0px auto;">
			<div>
				<p><span>设备编码:</span><label class="revokeDeviceCode"></label></p>
				<p><span>剩余流量(L):</span><label class="revokeResidueFlux"></label></p>
			</div>
			<div >
				<p><span>用户名:</span><label class="revokeGetUserName"></label></p>
				<p><span>剩余天数(D):</span><label class="revokeResidueDays"></label></p>
			</div>
			<div>
				<p><span>安装地址:</span><label class="revokeGetAddress"></label></p>
			</div>
			<p><textarea class="textareaBox revokeAddText" placeholder="备注信息："></textarea></p>
			<label style="color:#63C3D1;">每条充值记录只能撤销操作一次，请谨慎操作</label>
			<div class="payBox">撤回天数(天)：<input class="chargeFluxBox revokeFluxBox" type="text" placeholder="输入正整数" oninput="myFunction2()"/><label class="required">*</label></div>
			<div><label class="labelBox"></label></div>
		</div>
		<div class="btnBox" style="margin-top: 0px;">
			<a class="noBtn revokeNoBtn">取消</a>
			<a class="okBtn revokeOkBtn">确定</a>
		</div>
	</div>
	<script>
		var reg =/^[0-9]*$/;
		function myFunction1(){
			if(!reg.test($(".meterageM .revokeFluxBox").val())){
				$(".meterageM .labelBox").html("请输入正整数！");
				$(".meterageM .fluxNumBox").html(0);

			}else if($(".meterageM .revokeFluxBox").val()==0){
				$(".meterageM .labelBox").html("请输入正整数！");
				$(".meterageM .fluxNumBox").html(0);
			}else{
				$(".meterageM .labelBox").html("");
				$(".meterageM .fluxNumBox").html(Math.round($(".meterageM .revokeFluxBox").val()/$(".meterageM .revokePrice").html()));
			}
		}
		function myFunction2(){
			if(!reg.test($(".packageM .revokeFluxBox").val())){
				$(".packageM .labelBox").html("请输入正整数！");
				$(".packageM .fluxNumBox").html(0);

			}else if($(".packageM .revokeFluxBox").val()==0){
				$(".packageM .labelBox").html("请输入正整数！");
				$(".packageM .fluxNumBox").html(0);
			}else{
				$(".packageM .labelBox").html("");
			}
		}
	</script>
@stop
